<?php
namespace Index\Controller;
use Think\Controller;
use Index\Controller\CommonController;
class UserController extends CommonController {
    public function settingsAction(){
		$id = $_SESSION['id'];
    	$sql = "select * from  user where id ='{$id}'";
    	$res = M()->query($sql);

    	$this->assign('user',current($res));
       	$this->display();
    }

    public function faceAction()
    {
    	$this->display();
    }


    public function showAction()
    {
    	$this->display();
    }

    public function uploadfaceAction()
    {
    	$upload = new \Think\Upload();// 实例化上传类
	    $upload->maxSize   =     3145728 ;// 设置附件上传大小
	    $upload->exts      =     array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
	    $upload->rootPath  =     './Uploads/'; // 设置附件上传根目录
	    $upload->savePath  =     ''; // 设置附件上传（子）录目
	    // 上传文件 
	    $info   =   $upload->upload();
	    if(!$info) {// 上传错误提示错误信息
	        echo $upload->getError();
	    }else{// 上传成功
	        $face = '/Uploads/'.$info['upload_file']['savepath'].$info['upload_file']['savename'];
	        $id = $_SESSION['id'];
	        $sql = "update user set face='{$face}' where id='{$id}'";

	        $res = M()->execute($sql);

	        $_SESSION['face']=$face;
	        
	        if($res){
	        	echo $face;
	        }else{
	        	echo '1';
	        }
	    }
    }

    public function checkmailAction()
    {
    	var_dump($_GET);
    }
}